package com.mxpio.erp.common.inventory.entity;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.mxpio.erp.common.technology.entity.Item;
import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_INV_FLOW")
@Schema(description="库存流水")
public class InvFlow extends BaseEntity {
	
	public InvFlow() {
		super();
	}


	public InvFlow(String itemCode, String accessType, BigDecimal quantity) {
		super();
		this.accessType = accessType;
		this.itemCode = itemCode;
		this.quantity = quantity;
	}


	private static final long serialVersionUID = 1L;
	
	@Id
	@Column(name = "ID_", updatable = false)
	@Generator
	@Schema(description = "流水号")
	private String id;

	@Column(name = "ACCESS_TYPE_")
	@Schema(description = "出入类型")
	private String accessType;
	
	@Column(name = "ITEM_CODE_")
	@Schema(description = "物料代码")
	private String itemCode;
	
	@Column(name = "QUANTITY_")
	@Schema(description = "数量")
	private BigDecimal quantity;
	
	@Column(name = "LOT_NO_")
	@Schema(description = "批次号")
	private String lotNo;

	@Column(name = "SUB_LOT_INDEX_")
	@Schema(description = "子批次索引号")//无子批默认为0
	private String subLotIndex;

	@Column(name = "ORIGIN_BIZ_NO_")
	@Schema(description = "来源单号")
	private String originBizNo;
	
	@Column(name = "ORIGIN_BIZ_TYPE_")
	@Schema(description = "来源单据类型")
	private String originBizType;
	
	@Column(name = "ORIGIN_BIZ_LINE_NO_")
	@Schema(description = "来源单行号")
	private String originBizLineNo;
	
	@Column(name = "WO_BIZ_NO_")
	@Schema(description = "仓单单号")
	private String woBizNo;
	
	@Column(name = "WO_BIZ_LINE_NO_")
	@Schema(description = "仓单行号")
	private String woBizLineNo;
	
	@Column(name = "WO_BIZ_TYPE_")
	@Schema(description = "仓单类型")
	@Dict(dicCode = "ERP_INV_WO_TYPE")
	private String woBizType;
	
	@Column(name = "WH_CODE_")
	@Schema(description = "仓库编号")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;
	
	@Column(name = "MEMO_")
	@Schema(description = "备注")
	private String memo;


	@Transient
	@Schema(description = "物料名称")
	private String itemName;

	@Transient
	@Schema(description = "物料组")
	@Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String itemGroupCode;

	@Transient
	@Schema(description = "物料规格")
	private String itemSpec;

	@Transient
	@Schema(description = "单位编号")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String unitCode;

	@Column(name = "ORIGIN_NOTICE_NO_")
	@Schema(description = "来源通知单单号")
	private String originNoticeNo;

	@Column(name = "ORIGIN_NOTICE_LINE_NO_")
	@Schema(description = "来源通知单行号")
	private String originNoticeLineNo;


	@Transient
	private Item item;
}
